//
//  DetailEmergencyViewController.m
//  Qihuo
//
//  Created by Vencoo on 13-11-14.
//  Copyright (c) 2013年 Vencoo. All rights reserved.
//
#define characterLong 650
#import "DetailEmergencyViewController.h"
#import "EmergencyViewController.h"
@interface DetailEmergencyViewController ()
{
    NSDictionary *queryDataDic;
}
@end

@implementation DetailEmergencyViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"详细信息";
    
    UILabel *newsTitle = [UILabel new];
    newsTitle.text = [self.emdDelegate.queryDic valueForKey:@"address"];
    newsTitle.font = [UIFont systemFontOfSize:35];
    newsTitle.backgroundColor = [UIColor clearColor];
    newsTitle.textColor = [UIColor whiteColor];
    CGSize fontSize = [newsTitle.text sizeWithFont:newsTitle.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    if (fontSize.width > 1000) {
        fontSize.width = 1000;
    }
    if (_iOS7) {
        newsTitle.frame = CGRectMake((scrennWidth - fontSize.width)/2, 84, fontSize.width, fontSize.height);
    }else{
        newsTitle.frame = CGRectMake((scrennWidth - fontSize.width)/2, 64, fontSize.width, fontSize.height);
    }
    [self.view addSubview:newsTitle];
    
    UIImage *whiteimage = [UIImage imageNamed:@"底框-白.png"];
    UIImageView *MyView = [[UIImageView alloc]initWithFrame:CGRectMake((scrennWidth - whiteimage.size.width)/2, newsTitle.frame.origin.y + 86, whiteimage.size.width, whiteimage.size.height)];
    MyView.image = whiteimage;
    [MyView setUserInteractionEnabled:YES];
    [self.view addSubview:MyView];
    
    UILabel *dateLb = [UILabel new];
    dateLb.text = [queryDataDic valueForKey:@"crttime"];
    dateLb.font = [UIFont systemFontOfSize:24];
    dateLb.backgroundColor = [UIColor clearColor];
    dateLb.textColor = [UIColor whiteColor];
    fontSize = [dateLb.text sizeWithFont:dateLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    dateLb.frame = CGRectMake(1004 - fontSize.width, newsTitle.frame.origin.y + newsTitle.frame.size.height + 10, fontSize.width, fontSize.height);
    [self.view addSubview:dateLb];
    
    UILabel *personLb = [UILabel new];
    personLb.text = [queryDataDic valueForKey:@"crtuser"];
    personLb.font = [UIFont systemFontOfSize:24];
    personLb.backgroundColor = [UIColor clearColor];
    personLb.textColor = [UIColor whiteColor];
    fontSize = [personLb.text sizeWithFont:personLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    personLb.frame = CGRectMake(1004 - fontSize.width - dateLb.frame.size.width - interval111, newsTitle.frame.origin.y + newsTitle.frame.size.height + 10, fontSize.width, fontSize.height);
    [self.view addSubview:personLb];
    
    UIScrollView *myScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, whiteimage.size.width, whiteimage.size.height)];
    myScrollView.backgroundColor = [UIColor clearColor];
    [MyView addSubview:myScrollView];
    
#pragma mark - 第一行
    
//    NSDateFormatter *dateFormatter = [NSDateFormatter new];
//    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    
    UILabel *selTimeLb = [UILabel new];
    selTimeLb.text = [self.emdDelegate.queryDic valueForKey:@"crttime"];
    selTimeLb.font = [UIFont systemFontOfSize:chara+2];
    selTimeLb.backgroundColor = [UIColor clearColor];
    selTimeLb.textColor = [UIColor whiteColor];
    CGSize sz = [selTimeLb.text sizeWithFont:selTimeLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    selTimeLb.frame = CGRectMake(MyView.frame.origin.x + MyView.frame.size.width - sz.width ,MyView.frame.origin.y - sz.height, sz.width, sz.height);
    [self.view addSubview:selTimeLb];
    
    //    地点
    #pragma mark - 第二行 系统影响情况
    UILabel *systemLb = [UILabel new];
    systemLb.text = @"系统影响情况：";
    systemLb.font = [UIFont systemFontOfSize:chara];
    systemLb.backgroundColor = [UIColor clearColor];
    sz = [systemLb.text sizeWithFont:systemLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    systemLb.frame = CGRectMake(103, interval111, sz.width, sz.height);
    [myScrollView addSubview:systemLb];
    
   UILabel *systemTf = [UILabel new];
    systemTf.font = [UIFont systemFontOfSize:22];
    systemTf.text = [self.emdDelegate.queryDic valueForKey:@"systemcase"];
    sz = [systemTf.text sizeWithFont:systemTf.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    systemTf.numberOfLines = 0;
    systemTf.frame = CGRectMake(systemLb.frame.origin.x + systemLb.frame.size.width, systemLb.frame.origin.y, characterLong,(int)(sz.width/characterLong + 1)*sz.height);
    [myScrollView addSubview:systemTf];
    
    UILabel *reportLb = [UILabel new];
    reportLb.text = @"报告情况：";
    reportLb.font = [UIFont systemFontOfSize:chara];
    reportLb.backgroundColor = [UIColor clearColor];
    sz = [reportLb.text sizeWithFont:reportLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    reportLb.frame = CGRectMake(systemLb.frame.origin.x + chara*2,systemTf.frame.size.height + interval111 + systemTf.frame.origin.y, sz.width, sz.height);
    [myScrollView addSubview:reportLb];
    
    UILabel *reportTf = [UILabel new];
    reportTf.font = [UIFont systemFontOfSize:22];
    reportTf.text = [self.emdDelegate.queryDic valueForKey:@"reporting"];
    sz = [reportTf.text sizeWithFont:reportTf.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    reportTf.frame = CGRectMake(systemTf.frame.origin.x ,reportLb.frame.origin.y, systemTf.frame.size.width, (int)(sz.width/characterLong + 1)*sz.height);
    [reportTf setNumberOfLines:0];//自动换行
    [myScrollView addSubview:reportTf];
    
    UILabel *dealLb = [UILabel new];
    dealLb.text = @"接到报告后处理：";
    dealLb.font = [UIFont systemFontOfSize:chara];
    dealLb.backgroundColor = [UIColor clearColor];
    sz = [dealLb.text sizeWithFont:dealLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    dealLb.frame = CGRectMake(systemLb.frame.origin.x - chara,reportTf.frame.size.height + interval111 + reportTf.frame.origin.y, sz.width, sz.height);
    [myScrollView addSubview:dealLb];
    
    UILabel *dealTf = [UILabel new];
    dealTf.font = [UIFont systemFontOfSize:22];
    dealTf.text = [self.emdDelegate.queryDic valueForKey:@"handle"];
    sz = [dealTf.text sizeWithFont:dealTf.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    dealTf.frame = CGRectMake(reportTf.frame.origin.x ,dealLb.frame.origin.y, reportTf.frame.size.width, (int)(sz.width/characterLong + 1)*sz.height);
    dealTf.numberOfLines = 0;
    [myScrollView addSubview:dealTf];
    
    UILabel *resultLb = [UILabel new];
    resultLb.text = @"结果：";
    resultLb.font = [UIFont systemFontOfSize:chara];
    resultLb.backgroundColor = [UIColor clearColor];
    sz = [resultLb.text sizeWithFont:resultLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    resultLb.frame = CGRectMake(systemLb.frame.origin.x + chara * 4,dealTf.frame.size.height + interval111 + dealTf.frame.origin.y, sz.width, sz.height);
    [myScrollView addSubview:resultLb];
    
    UILabel *resultTf = [UILabel new];
    resultTf.font = [UIFont systemFontOfSize:22];
    resultTf.text = [self.emdDelegate.queryDic valueForKey:@"result"];
    resultTf.numberOfLines = 0;
    sz = [resultTf.text sizeWithFont:resultTf.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    resultTf.frame = CGRectMake(dealTf.frame.origin.x,resultLb.frame.origin.y, reportTf.frame.size.width, (int)(sz.width/characterLong + 1)*sz.height);
    [myScrollView addSubview:resultTf];
    
    UILabel *analyseLb = [UILabel new];
    analyseLb.text = @"分析：";
    analyseLb.font = [UIFont systemFontOfSize:chara];
    analyseLb.backgroundColor = [UIColor clearColor];
    sz = [analyseLb.text sizeWithFont:analyseLb.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    analyseLb.frame = CGRectMake(systemLb.frame.origin.x + chara * 4,resultTf.frame.size.height + interval111 + resultTf.frame.origin.y, sz.width, sz.height);
    [myScrollView addSubview:analyseLb];
    
    UILabel *analyseTf = [UILabel new];
    analyseTf.font = [UIFont systemFontOfSize:22];
    analyseTf.text = [self.emdDelegate.queryDic valueForKey:@"analysis"];
    sz = [analyseTf.text sizeWithFont:analyseTf.font constrainedToSize:CGSizeMake(MAXFLOAT, 40)];
    analyseTf.numberOfLines = 0;
    analyseTf.frame = CGRectMake(resultTf.frame.origin.x, analyseLb.frame.origin.y, reportTf.frame.size.width, (int)(sz.width/characterLong + 1)*sz.height);
    [myScrollView addSubview:analyseTf];
    
    myScrollView.contentSize = CGSizeMake(whiteimage.size.width, analyseTf.frame.size.height+analyseTf.frame.origin.y + interval111);

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
